// coupon.js
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // currentIndex: 0,
        url1: '../../img/images_03-01.png',
        url2: '../../img/images_3-01.png',
        pageIndex: 1,

    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        wx.request({
            url: app.data.baseUrl + '/AibraUsb/userCoupon/list.do',
            data: {
                openId: app.globalData.openid,
                pageIndex: that.data.pageIndex
            },
            success: function(res) {
                that.setData({
                    userCouponList: res.data.userCouponList
                })
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    scrolltolower: function() {
        var that = this
        var pageIndex = that.data.pageIndex;
        wx.request({
            url: app.data.baseUrl + '/AibraUsb/userCoupon/list.do',
            data: {
                openId: app.globalData.openid,
                pageIndex: that.data.pageIndex
            },
            success: function(res) {

                var userCouponList1 = res.data.userCouponList;
                var userCouponList2 = that.data.userCouponList;

                userCouponList2 = userCouponList2.concat(userCouponList1)
                pageIndex = ++pageIndex;
                that.setData({
                    userCouponList: userCouponList2,
                    pageIndex: pageIndex
                })
            },
            fail: function() {
                console.log("失败")
            }
        })
    },
})